<?php
/**
 * Created by PhpStorm.
 * User: Guangpeng Chen
 * Date: 9-28/0028
 * Time: 15:32
 */
if(!defined('ROOTPATH')) {
    define('ROOTPATH','/var/www/html/new/');
    define('CLASSPATH',ROOTPATH .'d/class/');
    define('TPLPATH',ROOTPATH .'d/tpl/');
    define('COMMONPATH',ROOTPATH .'d/common/');
    define('PROD_IMG_PATH',ROOTPATH .'d/prodimgs/');
}
include ROOTPATH  ."com.inc.php";
include CLASSPATH ."OrderRecord.php";
include CLASSPATH ."ProOrder.php";
include CLASSPATH ."SoapInit.class.php";
include CLASSPATH ."MemberAccount.class.php";

function ChkLogin()
{
    if(!isset($_SESSION['memberID'])){
        exit('{"code":102}');
    }
    if(!in_array($_SESSION['dtype'], array(0,2,9))) {
        exit('{"code":100}');
    }
}

function SalerList()
{
    if($_SESSION['dtype']==2) {
        $mem     = new \pft\Member\MemberAccount($GLOBALS['le']);
        $account = $mem->getAccountById($_SESSION['memberID']);
    }
    $sql = "SELECT salerid,title,getPY(title,1) AS py FROM uu_land WHERE";
    if(isset($_GET['sid'])) {
        $sql .= " id = " . intval($_GET['sid']);
    }
    elseif(isset($account)) {
        $sql .= " salerid={$account} AND status=1";
    }
    else {
        $sql .= " apply_did={$_SESSION['memberID']} AND status=1";
    }
    $sql .= " ORDER BY py ASC";
    $GLOBALS['le']->query($sql);
    $salerids = array();
    while($r = $GLOBALS['le']->fetch_assoc()) {
        $salerids[$r['salerid']] = $r['py'] . '-'.$r['title'];
    }
    return $salerids;
}